package org.qiyu.live.id.generate.provider.mapper;

import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;
import org.qiyu.live.id.generate.provider.entity.IdGeneratePO;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.qiyu.live.id.generate.provider.service.bo.LocalSeqIdBO;

import java.util.List;

/**
* @author c
* @description 针对表【t_id_generate_config】的数据库操作Mapper
* @createDate 2024-02-29 15:13:29
* @Entity org.qiyu.live.id.generate.provider.entity.IdGeneratePO
*/
@Mapper
public interface IdGenerateMapper extends BaseMapper<IdGeneratePO> {

    @Select("select * from t_id_generate_config")
    List<IdGeneratePO> selectAll();

    @Update("update t_id_generate_config set next_threshold=next_threshold+step," +
            "current_start=current_start+step,version=version+1 where id =#{id} and version=#{version}")
    int updateNewIdCountAndVersion(Integer id, Integer version);
}




